//
//  BCFriendScrollView.m
//  BangcaiBuy
//
//  Created by lsy on 16/7/6.
//  Copyright © 2016年 BCB. All rights reserved.
//

#import "BCFriendScrollView.h"
#import "BCFriendModel.h"
@implementation BCFriendScrollView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self viewPrepare];
    }
    return self;
}
/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */

- (void)setArr:(NSMutableArray *)arr
{
    _arr = arr;
    [self viewPrepare];
}

- (void)viewPrepare
{
    self.scroll = [[UIScrollView alloc] initWithFrame:self.frame];
    self.scroll.contentSize = CGSizeMake(SCREEN_WIDTH * self.arr.count , SCREEN_HEIGHT);
    self.scroll.backgroundColor = [UIColor yellowColor];
    self.scroll.pagingEnabled = YES;
    [self addSubview:self.scroll];
    self.scroll.showsHorizontalScrollIndicator = NO;
    self.scroll.showsVerticalScrollIndicator = NO;
    self.startButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.scroll.bounces = NO;
    for (NSInteger i = 0; i < self.arr.count; i++) {
        UIImageView *imageViewAll = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH * i, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
        BCFriendModel *model = self.arr[i];
        imageViewAll.image = model.image;
        [self.scroll addSubview:imageViewAll];
        if (i == 2) {
            imageViewAll.userInteractionEnabled = YES;
            [imageViewAll addSubview:self.startButton];
            [self.startButton mas_makeConstraints:^(MASConstraintMaker *make) {
                make.width.mas_equalTo(200 *wx);
                make.height.mas_equalTo(50 *hx);
                make.centerX.mas_equalTo(0);
                make.top.mas_equalTo(600 *hx);
            }];
        }
        
    }
    
}

@end
